#include "encoder.h"


void encoder_init(void)
{

 ctimer_count_init( PULSE_LEFT );
 ctimer_count_init( PULSE_RIGHT );


}
int16 left_encoder=0;
int16 right_encoder=0;

void encoder_scan(void)
{
  left_encoder=ctimer_count_read(PULSE_LEFT);
	
	if(DIR_LEFT==1)    {left_encoder=left_encoder;}
	else               {left_encoder=-left_encoder;} 
	ctimer_count_clean(PULSE_LEFT);
	right_encoder=ctimer_count_read(PULSE_RIGHT);
	
	if(DIR_RIGHT==1)    {right_encoder=-right_encoder;}
	else               {right_encoder=right_encoder;} 
	ctimer_count_clean(PULSE_RIGHT);
	
	
	
}

